import java.util.Arrays;
import java.util.Comparator;

/**
 * @author zhu
 * @date 2024-04-09
 */
public class MainTest {
    public static void main(String[] args) {
        // 定义一个Student型数组
        Student stu1 = new Student("张三",18);
        Student stu2 = new Student("李四",22);
        Student stu3 = new Student("王五",21);
        Student[] students = {stu1,stu2,stu3};

        // 使用 Arrays.sort() 和 Lambda 表达式实现降序排序
        Arrays.sort(students,(a,b) -> b.getAge() - a.getAge() );

        // 打印输出排序的结果
        System.out.println("排序后的结果：" + Arrays.toString(students));
    }
}
